﻿<script type="text/javascript">  
	$(document).ready(function(){  
		$("#tableorder").flexigrid(
		{
			url:'http://shoppingcartcnpm.orgfree.com/index.php/Longadmin/order/list',
			dataType: 'json',
			colModel : [
				{display: 'OID', name : 'o_id', width : 40, sortable : true, align: 'center'},
				{display: 'Khách Hàng', name : 'u_id', width : 100, sortable : true, align: 'center'},
				{display: 'HT Vận Chuyển', name : 'ship_id', width : 120, sortable : true, align: 'center'},
				{display: 'HT Thanh Toán', name : 'p_ten', width : 120, sortable : true, align: 'center'},
				{display: 'Ngày Đặt', name : 'o_ngaydat', width : 100, sortable : true, align: 'center'},
				{display: 'TT Đơn Hàng', name : 'os_id', width : 100, sortable : true, align: 'center'},
				{display: 'TT Thanh Toán', name : 'ps_id', width : 100, sortable : true, align: 'center'},
				],

			buttons : [
				{name: 'Add', bclass: 'add',onpress : test},
				{name: 'Delete', bclass: 'delete',onpress : test},
				{separator: true}
				],
			searchitems : [
				{display: 'OID', name : 'o_id'},
				{display: 'Khách Hàng', name : 'u_id', isdefault: true}
				],
			title:'Đơn Đặt Hàng',
			usepager: true,
			userRp:true,
			singleSelect: true,
			showTableToggleBtn: true,
			rp:8,
			width:770,
			height:200,
			
		}
		);
			
		function test(com,grid) 
			{
				if (com=='Delete')
					{
						$('.trSelected', grid).each(function() {
							var id = $(this).attr('id');
							id = id.substring(id.lastIndexOf('row')+3);
							alert("Delete order " + id);
							$.nyroModalManual({
								url: 'http://shoppingcartcnpm.orgfree.com/index.php/Longadmin/order/delete?id='+id,
								width: 500, // default Width If null, will be calculate automatically
								height: 500, // default Height If null, will be calculate automatically
								minWidth: null, // Minimum width
								minHeight: null, // Minimum height
							});	
						});
					}
				else if (com=='Add')
					{
						alert('Add New Item');
						$.nyroModalManual({
							url: 'http://shoppingcartcnpm.orgfree.com/index.php/Longadmin/product/add',
							width: 500, // default Width If null, will be calculate automatically
							height: 500, // default Height If null, will be calculate automatically
							minWidth: null, // Minimum width
							minHeight: null, // Minimum height
						});	
					}			
			}
			

	});	
</script>
<table id = "tableorder" style="display:none">
</table>	